import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  RequestParams,
  LibraryPageVo,
  ResponseData,
  Params,
  bookReturn,
} from "./types";

/**
 * 列表数据
 * @param data {LoginData}
 * @returns
 */
export function getLibraryList(
  data: RequestParams
): AxiosPromise<ResponseData<LibraryPageVo>> {
  return request({
    url: "/api/v1/inventoryTask/page",
    method: "post",
    data,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
}
// export const loginApi =(params:LoginData)=>{
//   return request.post<LoginResult>('/api/v1/auth/login',params)
// }
/**
 * 下拉列表数据
 */

export function libraryaOptions(
  params: Params
): AxiosPromise<ResponseData<bookReturn>> {
  return request({
    url: `/api/v1/inventoryTaskDetail/tempPage`,
    method: "get",
    params,
  });
}
export const inventoryRouteOptions = (aesKeyByRsa: string) => {
  return request<ResponseData<any>>({
    url: "/api/v1/inventoryRoute/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const inventoryTask = (aesKeyByRsa: string) => {
  return request<ResponseData<any>>({
    url: "/api/v1/inventoryTask/startTask",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const LibraryOptions = (aesKeyByRsa: string) => {
  return request<ResponseData<any>>({
    url: "/api/v1/library/options",
    method: "post",
    data: aesKeyByRsa,
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
export const controlTaskChange = (controlType: any, taskId: any) => {
  return request<ResponseData<any>>({
    url: "/api/v1/inventoryTask/controlTask",
    method: "post",
    data: {
      controlType,
      taskId,
    },
    headers: {
      //需要加密的请求在头部塞入标识
      isEncrypt: 1,
    },
  });
};
